19. Continuous Integration

Continuous Integration

ND079 JPND C3 L5 A13 Continuous Integration

CI/CD - Continous Integration / Continuous Delivery

Continuous Integration refers to the process of automatically running unit tests any time your code changes. It usually is performed by a service that monitors the state of your repository and runs all your unit tests whenever you commit new changes.

Continuous Delivery is a process that follows CI and involves creating deployable build artifacts every time the project changes.

Containerization means creating a self-contained environment with known parameters to build and run your application.

Docker is an application that provides a container format and an engine that can run those containers.

Demo

ND079 JPND C3 L5 A14 Demo Continuous Integration

CircleCI and GitHub

The above video demonstrates how to set up a new CircleCI project for a GitHub repository. You will need an account with https://github.com/ if you wish to follow along. It goes through the following steps:

  1. Create a new repository on GitHub
  2. Check out the repository and copy a Java project into the repository. The demo uses the project lesson6 from the solutions set because it has a variety of unit tests in it, but any Java Maven project will work for our example.
  3. Push your change to the repository.
  4. Navigate to app.circleci.com and log in with your GitHub account.
  5. Click on the Projects tab and then **Set Up Project **from the repository you just created.
  6. Select **Maven(Java) **from the dropdown.
  7. Update the orbs: maven: to use version circleci/maven@1.0.3 and then press Add Config. CircleCI creates a new file called config.yml in the directory .circleci and pushes this change to a new branch called circleci-project-setup.
  8. Click into the running project. The Run Test step fails, because our Java Version of 14 is higher than the default Docker install (which uses Java 13)
  9. Modify the file .circleci/config.yml on the circleci-project-setup branch to use a different docker image (file below) and push the change to the repository.
  10. Go back to CircleCI and observe the build finish successfully.

config.yml

version: 2.1

orbs:
  maven: circleci/maven@1.0.3
executors:
  docker-java:
    docker:
    - image: cimg/openjdk:14.0.0
workflows:
  maven_test:
    jobs:
      - maven/test:
          executor: docker-java